<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: Square</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.board</a> ]
    </div>

    <h1>Coverage Summary for Class: Square (nl.tudelft.jpacman.board)</h1>

    <table class="coverageStats">

        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">Square</td>
            <td class="coverageStat">
  <span class="percent">
    12.5%
  </span>
                <span class="absValue">
    (1/ 8)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    4.3%
  </span>
                <span class="absValue">
    (1/ 23)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$1INQMV1s</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$7jfHYwo9</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$EvNYYGtN</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$KVdAhIMU</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$RDUP8pUO</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$TbQL45QC</td>
        </tr>
        <tr>
            <td class="name">Square$MockitoMock$1070600087$auxiliary$zE2N3Sa3</td>
        </tr>
        <tr>
            <td class="name"><strong>total</strong></td>
            <td class="coverageStat">
  <span class="percent">
    12.5%
  </span>
                <span class="absValue">
    (1/ 8)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    4.3%
  </span>
                <span class="absValue">
    (1/ 23)
  </span>
            </td>
        </tr>
    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.board;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import java.util.ArrayList;
        <i>4</i>&nbsp;import java.util.EnumMap;
        <i>5</i>&nbsp;import java.util.List;
        <i>6</i>&nbsp;import java.util.Map;
        <i>7</i>&nbsp;
        <i>8</i>&nbsp;import com.google.common.collect.ImmutableList;
        <i>9</i>&nbsp;
        <i>10</i>&nbsp;import nl.tudelft.jpacman.sprite.Sprite;
        <i>11</i>&nbsp;
        <i>12</i>&nbsp;/**
        <i>13</i>&nbsp; * A square on a {@link Board}, which can (or cannot, depending on the type) be
        <i>14</i>&nbsp; * occupied by units.
        <i>15</i>&nbsp; *
        <i>16</i>&nbsp; * @author Jeroen Roosen
        <i>17</i>&nbsp; */
        <b class="fc"><i>18</i>&nbsp;public abstract class Square {</b>
        <i>19</i>&nbsp;
        <i>20</i>&nbsp; /**
        <i>21</i>&nbsp; * The units occupying this square, in order of appearance.
        <i>22</i>&nbsp; */
        <i>23</i>&nbsp; private final List&lt;Unit&gt; occupants;
        <i>24</i>&nbsp;
        <i>25</i>&nbsp; /**
        <i>26</i>&nbsp; * The collection of squares adjacent to this square.
        <i>27</i>&nbsp; */
        <i>28</i>&nbsp; private final Map&lt;Direction, Square&gt; neighbours;
        <i>29</i>&nbsp;
        <i>30</i>&nbsp; /**
        <i>31</i>&nbsp; * Creates a new, empty square.
        <i>32</i>&nbsp; */
        <b class="nc"><i>33</i>&nbsp; protected Square() {</b>
        <b class="nc"><i>34</i>&nbsp; this.occupants = new ArrayList&lt;&gt;();</b>
        <b class="nc"><i>35</i>&nbsp; this.neighbours = new EnumMap&lt;&gt;(Direction.class);</b>
        <b class="nc"><i>36</i>&nbsp; assert invariant();</b>
        <b class="nc"><i>37</i>&nbsp; }</b>
        <i>38</i>&nbsp;
        <i>39</i>&nbsp; /**
        <i>40</i>&nbsp; * Returns the square adjacent to this square.
        <i>41</i>&nbsp; *
        <i>42</i>&nbsp; * @param direction The direction of the adjacent square.
        <i>43</i>&nbsp; * @return The adjacent square in the given direction.
        <i>44</i>&nbsp; */
        <i>45</i>&nbsp; public Square getSquareAt(Direction direction) {
        <b class="nc"><i>46</i>&nbsp; return neighbours.get(direction);</b>
        <i>47</i>&nbsp; }
        <i>48</i>&nbsp;
        <i>49</i>&nbsp; /**
        <i>50</i>&nbsp; * Links this square to a neighbour in the given direction. Note that this
        <i>51</i>&nbsp; * is a one-way connection.
        <i>52</i>&nbsp; *
        <i>53</i>&nbsp; * @param neighbour The neighbour to link.
        <i>54</i>&nbsp; * @param direction The direction the new neighbour is in, as seen from this cell.
        <i>55</i>&nbsp; */
        <i>56</i>&nbsp; public void link(Square neighbour, Direction direction) {
        <b class="nc"><i>57</i>&nbsp; neighbours.put(direction, neighbour);</b>
        <b class="nc"><i>58</i>&nbsp; assert invariant();</b>
        <b class="nc"><i>59</i>&nbsp; }</b>
        <i>60</i>&nbsp;
        <i>61</i>&nbsp; /**
        <i>62</i>&nbsp; * Returns an immutable list of units occupying this square, in the order in
        <i>63</i>&nbsp; * which they occupied this square (i.e. oldest first.)
        <i>64</i>&nbsp; *
        <i>65</i>&nbsp; * @return An immutable list of units occupying this square, in the order in
        <i>66</i>&nbsp; * which they occupied this square (i.e. oldest first.)
        <i>67</i>&nbsp; */
        <i>68</i>&nbsp; public List&lt;Unit&gt; getOccupants() {
        <b class="nc"><i>69</i>&nbsp; return ImmutableList.copyOf(occupants);</b>
        <i>70</i>&nbsp; }
        <i>71</i>&nbsp;
        <i>72</i>&nbsp; /**
        <i>73</i>&nbsp; * Adds a new occupant to this square.
        <i>74</i>&nbsp; *
        <i>75</i>&nbsp; * @param occupant The unit to occupy this square.
        <i>76</i>&nbsp; */
        <i>77</i>&nbsp; void put(Unit occupant) {
        <b class="nc"><i>78</i>&nbsp; assert occupant != null;</b>
        <b class="nc"><i>79</i>&nbsp; assert !occupants.contains(occupant);</b>
        <i>80</i>&nbsp;
        <b class="nc"><i>81</i>&nbsp; occupants.add(occupant);</b>
        <b class="nc"><i>82</i>&nbsp; }</b>
        <i>83</i>&nbsp;
        <i>84</i>&nbsp; /**
        <i>85</i>&nbsp; * Removes the unit from this square if it was present.
        <i>86</i>&nbsp; *
        <i>87</i>&nbsp; * @param occupant The unit to be removed from this square.
        <i>88</i>&nbsp; */
        <i>89</i>&nbsp; void remove(Unit occupant) {
        <b class="nc"><i>90</i>&nbsp; assert occupant != null;</b>
        <b class="nc"><i>91</i>&nbsp; occupants.remove(occupant);</b>
        <b class="nc"><i>92</i>&nbsp; }</b>
        <i>93</i>&nbsp;
        <i>94</i>&nbsp; /**
        <i>95</i>&nbsp; * Verifies that all occupants on this square have indeed listed this square
        <i>96</i>&nbsp; * as the square they are currently occupying.
        <i>97</i>&nbsp; *
        <i>98</i>&nbsp; * @return &lt;code&gt;true&lt;/code&gt; iff all occupants of this square have this
        <i>99</i>&nbsp; * square listed as the square they are currently occupying.
        <i>100</i>&nbsp; */
        <i>101</i>&nbsp; protected final boolean invariant(Square this) {
        <b class="nc"><i>102</i>&nbsp; for (Unit occupant : occupants) {</b>
        <b class="nc"><i>103</i>&nbsp; if (occupant.hasSquare() &amp;&amp; occupant.getSquare() != this) {</b>
        <b class="nc"><i>104</i>&nbsp; return false;</b>
        <i>105</i>&nbsp; }
        <b class="nc"><i>106</i>&nbsp; }</b>
        <b class="nc"><i>107</i>&nbsp; return true;</b>
        <i>108</i>&nbsp; }
        <i>109</i>&nbsp;
        <i>110</i>&nbsp; /**
        <i>111</i>&nbsp; * Determines whether the unit is allowed to occupy this square.
        <i>112</i>&nbsp; *
        <i>113</i>&nbsp; * @param unit The unit to grant or deny access.
        <i>114</i>&nbsp; * @return &lt;code&gt;true&lt;/code&gt; iff the unit is allowed to occupy this square.
        <i>115</i>&nbsp; */
        <i>116</i>&nbsp; public abstract boolean isAccessibleTo(Unit unit);
        <i>117</i>&nbsp;
        <i>118</i>&nbsp; /**
        <i>119</i>&nbsp; * Returns the sprite of this square.
        <i>120</i>&nbsp; *
        <i>121</i>&nbsp; * @return The sprite of this square.
        <i>122</i>&nbsp; */
        <i>123</i>&nbsp; public abstract Sprite getSprite();
        <i>124</i>&nbsp;
        <i>125</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
